package com.dranie.validator;

import com.dranie.entity.Category;
import com.jfinal.core.Controller;
import com.jfinal.validate.Validator;

/**
 * BlogValidator.
 */
public class CategoryValidator extends Validator {

	protected void validate(Controller controller) {
		validateRequiredString("category.name", "categoryName", "请输入商品类型!");
	}

	protected void handleError(Controller controller) {
		controller.keepModel(Category.class);

		String actionKey = getActionKey();
		if (actionKey.equals("/admin/category/save"))
			controller.render("add.html");
		else if (actionKey.equals("/admin/category/update"))
			controller.render("edit.html");
	}
}
